#include "os_test.h"
#include "../data_struct/head.h"
#include "../global/head.h"
#include "../macro/head.h"

//////////////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos_test
{

    os_test::os_test()
    {
    }

    os_test::~os_test()
    {
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////
    // 

    int os_test::test( int argc, const char  * argv[] )
    {
        int nRet = 0;

        if( 0 == nRet )
        {
            nRet = test_thread( argc, argv );
        }

        if( 0 == nRet )
        {
            nRet = test_xos( argc, argv );
        }

        if( 0 == nRet )
        {
            nRet = test_log( argc, argv );
        }

        return nRet;
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////
    // 

    int os_test::test_xos( int argc, const char  * argv[] )
    {
        using namespace std;
        int nRet = 0;

        char szGuid[100] = { 0 };

        if( 0 == nRet )
        {
            g_pSysData->m_pMisc->create_guid( szGuid );
            cout << "create guid = " << szGuid << endl;
        }

        if( 0 == nRet )
        {
            char szBuf[100] = { 0 };
            g_pSysData->m_pCrt->strcpy( szBuf, szGuid );
            cout << "copy guid = " << szBuf << endl;
        }

        return nRet;
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////
    // 

    int os_test::test_thread( int argc, const char  * argv[] )
    {
        using namespace std;
        int nRet = 0;

        xos::i_thread * pThread = 0;

        if( 0 == nRet )
        {
            nRet = g_pSysData->m_pXos->create( xos::i_xos::XOS_OBJ_THREAD, ( void ** )&pThread );
        }

        if( 0 == nRet )
        {
            nRet = pThread->create( thread_proc, 0 );
        }

        if( pThread )
        {
            pThread->wait();
            pThread->release();
            pThread = 0;
        }

        return nRet;
    }

    void * os_test::thread_proc( void * lpData )
    {
        using namespace std;
        cout << "this is in helper_thread_proc" << endl;
        return 0;
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////
    // 

    int os_test::test_log( int argc, const char  * argv[] )
    {
        using namespace std;
        int nRet = 0;

        LOG4( "%20s = %s", "log test", "test_log" );

        return nRet;
    }

} // xos
